#include "timer.h"

Timer::Timer(QObject *parent)
	: apiTimer(parent)
{
}

Timer::~Timer()
{
	_timer->deleteLater();
}

void						Timer::init()
{
	_interval = 100;
	_timer = new QTimer(this);
	connect(_timer, SIGNAL(timeout()), this, SLOT(update()));
	qDebug() << "Timer::init";
}

apiTimer					*Timer::getApi()
{
	init();
	return (new apiTimer(this));
}

void						Timer::update()
{
	_time += (unsigned int)_interval;
	//qDebug() << "time = " << _time;
}

void						Timer::start()
{
	_timer->start(_interval);
}

void						Timer::stop()
{
	_timer->stop();
}

void						Timer::restart()
{
	start();
}